package com.cuit.mapper;

import com.cuit.pojo.Article;
import com.cuit.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ArticleMapper {
    @Select("select * from article limit #{page},#{pageSize}")
    public List<Article> findAll(int page,int pageSize);
    @Select("select count(*) from article")
    public int countAll();
    @Select("select * from article where id = #{id}")
    public Article findById(int id);
    @Delete("delete from article where id = #{id}")
    public int deleteById(int id);
    @Insert("insert into article(id, title, text, like_num, dislike_num, click_num, created_date, updated_date, user_id) values (#{id},#{title},#{text},#{likeNum},#{dislikeNum},#{clickNum},#{createdDate},#{updatedDate},#{userId})")
    public int insertArticle(Article article);
    @Update("update article set title=#{title},text=#{text},like_num=#{likeNum},dislike_num=#{dislikeNum},click_num=#{clickNum},created_date=#{createdDate},updated_date=#{updatedDate},user_id=#{userId} where id=#{id}")
    public int updateById(Article article);
    @Select("select * from article where user_id=#{userId} limit #{page},#{pageSize}")
    public List<Article> findArticleByUserId(int userId,int page,int pageSize);
    @Select("select count(*) from article where user_id=#{userId}")
    public int countArticleByUserId();


    public List<Article> findArticleLikeSearchText(int page, int pageSize, String searchText);
}
